      SUBROUTINE ASCII ( STRING )
C*
C*                  *******************************
C*                  *******************************
C*                  **                           **
C*                  **          ASCII            **
C*                  **                           **
C*                  *******************************
C*                  *******************************
C*
C*     SUBPROGRAM :
C*          ASCII
C*
C*     AUTHOR :
C*          ART RAGOSTA
C*          MS 207-5
C*          AMES RESEARCH CENTER
C*          MOFFETT FIELD, CALIF  94035
C*          (415) 694-5578
C*
C*     PURPOSE :
C*          TO REPLACE TEXT STRINGS OF THE TYPE CREATED BY SUBROUTINE
C*          DASCII WITH ASCII CHARACTERS (SEE DASCII).
C*
C*     INPUT ARGUMENTS :
C*          STRING - STRING TO BE ASCIIFIED.
C*
C*     OUTPUT ARGUMENTS :
C*          STRING - ASCIIFIED STRING ( IN PLACE ).
C*
C*     INTERNAL WORK AREAS :
C*          WORK  - TEMPORARY STORAGE FOR STRING WHILE IT IS BUILT.
C*          TABLE - ASCII MNEMONIC STRINGS FOR CONTROL CHARACTERS.
C*
C*     COMMON BLOCKS :
C*          NONE
C*
C*     FILE REFERENCES :
C*          NONE
C*
C*     DATA BASE ACCESS :
C*          NONE
C*
C*     SUBPROGRAM REFERENCES :
C*          NONE
C*
C*     ERROR PROCESSING :
C*          NONE
C*
C*     TRANSPORTABILITY LIMITATIONS :
C*          NONE
C*
C*     ASSUMPTIONS AND RESTRICTIONS :
C*          NONE
C*
C*     LANGUAGE AND COMPILER :
C*          ANSI FORTRAN 77
C*
C*     VERSION AND DATE :
C*          VERSION I.0     30-JAN-85
C*
C*     CHANGE HISTORY :
C*          30-JAN-85    INITIAL VERSION
C*
C***********************************************************************
C*
      CHARACTER *255 WORK
      CHARACTER *(*) STRING
      CHARACTER *3 TABLE(0:32), THREE
      DATA TABLE /'NUL',  'SOH',  'STX',  'ETX',  'EOT',  'ENQ',
     $    'ACK',  'BEL',  ' BS',  ' HT',  ' LF',  ' VT',  ' FF',
     $    ' CR',  ' SO',  ' SI',  'DLE',  'DC1',  'DC2',  'DC3',
     $    'DC4',  'NAK',  'SYN',  'ETB',  'CAN',  ' EM',  'SUB',
     $    'ESC',  ' FS',  ' GS',  ' RS',  ' US',  'DEL' /
C
      L = LEN ( STRING )
      WORK = ' '
      IW = 0
      IS = 0
C
C --- DO WHILE NUMBER OF CHARACTERS IN WORK < NUMBER OF CHARACTERS IN STRING
C
100   IS = IS + 1
      IF (STRING(IS:IS) .EQ. '<') THEN
         IT = IS + 4
         IF ((IT .LE. L) .AND. (STRING(IT:IT) .EQ. '>')) THEN
C
C ------    IT APPEARS TO BE AN ASCII REPRESENTATION
C
            IS = IS + 1
            IT = IT - 1
            THREE = STRING(IS:IT)
C
C ------    SEE IF THE TEXT STRING IS AN ASCII CHARACTER MNEMONIC
C
            DO 110 I = 0,32
               IF (THREE .EQ. TABLE(I)) THEN
                  IW = IW + 1
                  IF (IW .GT. 255) GO TO 1000
                  IF (I .EQ. 32) THEN
                     WORK(IW:IW) = CHAR(127)
                  ELSE
                     WORK(IW:IW) = CHAR(I)
                  ENDIF
                  IS = IS + 3
                  IF (IS .LT. L) GO TO 100
                  GO TO 1000
               ENDIF
110            CONTINUE
C
C ------    NOT IN TABLE, SEE IF NUMERIC
C
            DO 120 I = 1,3
               IF((THREE(I:I) .LT. '0') .OR. (THREE(I:I) .GT. '9'))THEN
                  IW = IW + 1
                  IF (IW .GT. 255) GO TO 1000
                  WORK(IW:IW) = '<'
                  GO TO 200
               ENDIF
120            CONTINUE
C
C ------    ALL DIGITS
C
            READ ( THREE, 900 )I
            IF ((I .LE. 255) .AND. (I .GE. 128)) THEN
C
C ------    OK, ITS NUMERIC
C
               IS = IS + 3
               IW = IW + 1
               IF (IW .GT. 255) GO TO 1000
               WORK(IW:IW) = CHAR(I)
               IF (IS .LT. L) GO TO 100
               GO TO 1000
            ELSE
C
C -----   NOT NUMERIC, MUST BE COINCIDENCE
C
               IW = IW + 1
               IF (IW .GT. 255) GO TO 1000
               WORK(IW:IW) = '<'
            ENDIF
         ENDIF
      ENDIF
200   IW = IW + 1
      IF (IW .GT. 255) GO TO 1000
      WORK(IW:IW) = STRING(IS:IS)
      IF ( IS .LT. L ) GO TO 100
C
C --- END DO WHILE
C
C --- OUTPUT STRING FULL OR INPUT STRING DEPLETED
C
1000  STRING = WORK
      RETURN
900   FORMAT (I3)
      END
C
C---END ASCII
C
